< previous page page_131 next page >

Page 131
0131-01.jpg
Figure 4.9
Example program CurveTxt draws text along curves and circles.
Printers usually have a much higher resolution than a typical computer screen, so rotated fonts look much smoother when drawn directly on a printer.
Centering Rotated Text
Centering normal text is relatively easy. You can use the TextWidth and TextHeight functions to see how much room the string will occupy. Then you can subtract half of these values from coordinates of the string's desired center position. The following code shows how a program might center a string on a form.
e10a6a0a59f035e870d90cca05b85fce.gif
Private Sub Form_Load()
    CurrentX = ScaleWidth / 2 - TextWidth("Some Text") / 2
    CurrentY = ScaleHeight / 2 - TextHeight("Some Text") / 2
    Print "Some Text"
    Line (0, 0)-(ScaleWidth, ScaleHeight)
    Line (0, ScaleHeight)-(ScaleWidth, 0)
End Sub
The situation is much more complicated when the text is rotated. The TextWidth and TextHeight functions return the dimensions of the text as if it were not rotated; they do not return the dimensions of the rotated text. TextHeight can become confused when you use SelectObject to select a customized font, making its value completely useless.
Figure 4.10 shows the geometry of a rotated string. This picture seems intimidating, but it is manageable when considered in small pieces.

 
< previous page page_131 next page >